// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.commands.serverCommands;

import zombie.characters.IsoPlayer;
import zombie.commands.CommandBase;
import zombie.commands.CommandHelp;
import zombie.commands.CommandName;
import zombie.commands.RequiredRight;
import zombie.core.raknet.UdpConnection;
import zombie.network.GameServer;

@CommandName(
    name = "alarm"
)
@CommandHelp(
    helpText = "UI_ServerOptionDesc_Alarm"
)
@RequiredRight(
    requiredRights = 60
)
public class AlarmCommand extends CommandBase {
    public AlarmCommand(String username, String userAccessLevel, String command, UdpConnection connection) {
        super(username, userAccessLevel, command, connection);
    }

    @Override
    protected String Command() {
        IsoPlayer isoPlayer = GameServer.getPlayerByUserName(this.getExecutorUsername());
        if (isoPlayer != null && isoPlayer.getSquare() != null && isoPlayer.getSquare().getBuilding() != null) {
            isoPlayer.getSquare().getBuilding().getDef().bAlarmed = true;
            zombie.AmbientStreamManager.instance.doAlarm(isoPlayer.getSquare().getRoom().def);
            return "Alarm sounded";
        } else {
            return "Not in a room";
        }
    }
}
